<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <div v-for="itemList in dataList">
      <span v-for="item in itemList" @click="change(item.id)" class="aaa" :class="{selected:item.id==selectedId}">
          {{item.name}}
      </span>
      <div v-for="item in itemList">
        <div v-if="item.id==selectedId" style="background:#eee;">
          <span v-for="itemChild in item.childrenList">
            {{itemChild.name}}
          </span>
        </div>
      </div>
    </div>
  </div>

  
</body>
<script src="./jquery/jquery-1.9.1.min.js"></script>
<script src="./vue/vue.min.js"></script>
<script>
  var app = new Vue({
    el: '#app',
    data: {
      dataList:[],
      selectedId:1,
    },
    methods: {
      change:function(id){
        this.selectedId=id
      }
    },
    mounted: function () {
      var that=this
      $.ajax({
        type:"get", //使用get方式
        url: "./json/1.json", //json文件相对于这个HTML的路径
        dataType:"json",
        success:function(data) {
          //这个data就是json数据
          // that.dataList=data
          for(var i=0;i<data.length;i+=3){
            that.dataList.push(data.slice(i,i+3))
          }
          console.log(that.dataList)
        },
        error:function() {
          alert("请求失败");
        }
      });
    }
  })
  
</script>
<style>
  .aaa{
    cursor: pointer;
  }
  .selected{
    background-color: #000;
    color: #fff;
  }
</style>
</html>